!(function () {
  window.API = {
    //获取地图上所有数据
    getPointList(callback) {
      var temp = '美愿,美力,美物,美食,美宿,小故事,任务单,导游内容'.split(',');
      var arr = [];
      for (let i = 0; i < 30; i++) {
        let point = randPoint()
        var type = temp[randNumber(0, temp.length)]
        var imageObj = getImageUrl(type)
        var obj = {
          id: i + 1,
          type: type,
          longitude: point[1],
          latitude: point[0],
          minZoom: randNumber(11, 14),
          maxZoom: 25,
          soundUrl: window.LOCAL_ROOT + 'static/sound/10418',
          imageUrl: LOCAL_ROOT + 'static/image/' + imageObj.url,
          width: imageObj.width,
          height: imageObj.height
        }
        arr.push(obj)
      }
      setTimeout(() => {
        typeof callback === 'function' && callback(arr)
      }, 1000);
    }
  }

  function getImageUrl(type) {
    var url = '';
    var width = 0;
    var height = 0;
    if (type.indexOf('美') > -1) {
      url = 'point.png'
      width = 60;
      height = 40;
    } else if (type.indexOf('导游') > -1) {
      url = 'sound.png';
      width = 30;
      height = 20;
    } else {
      url = 'task.png';
      width = 15;
      height = 30;
    }
    return {
      url: url,
      width: width,
      height: height
    }
  }

  function randNumber(minNumber, maxNumber) {
    let z = ~~(Math.random() * (maxNumber - minNumber)) + minNumber;
    return z;
  }

  function isFront() {
    return Math.random() > 0.5;
  }

  function randPoint() {
    let x = Math.random() * 0.05 * (isFront() ? 1 : -1)
    let y = Math.random() * 0.05 * (isFront() ? 1 : -1)
    let re = [CENTER[0] + x, CENTER[1] + y]
    return re;
  }

})();